<?php
namespace models;  
/**
 * This code is property of Piotr Poradzisz. Do not distribute under threat of legal consequences.
 * All rights reserved.
 * Все права защищены.
 * Alle Rechte vorbehalten.
 * Todos los derechos reservados.
 * Wszelkie prawa zastrzeżone.
 *                  جميع الحقوق محفوظة
 * 保留所有权利
 * すべての著作権
 * @author Piotr Poradzisz
 * email: piotr.poradzisz@gmail.com
 * tel.: +48668027020
 */
class User extends Mysql{

    public function signIn($email, $password) {
        if(isset($email) and isset ($password)){
            $query = "  SELECT *
                        FROM user u
                        WHERE u.email = '$email' AND userType < 3 AND active = 1";
            $user = $this->getRow($query);
            if($user['password'] == md5($password)){
                $_SESSION['user'] = $user;
                $query = "UPDATE user SET lastLogin = NOW() WHERE id = $user[id]";
                $this->setQuery($query);
                return true;
            }
            else return false;
        }
        else return false;
    }
}
?>